<template>
  <div ref="echarts" class="echarts"></div>
</template>

<script>
import {reqAdminEcharts1} from '../../../../api'
export default {
    name:"Echarts1",
    async mounted() {
        let index = [6,5,4,3,2,1,0];let lineDate = [] //过去7天
        const date = new Date()
        const month = date.getMonth()+1
        const day = date.getDate()
        index.forEach(item => {
        lineDate.push(month + '-'+ (day - item))
        });
        const reqData = await reqAdminEcharts1()
        const echarts = this.$refs.echarts
        const echartsChart = this.$echarts.init(echarts);
        const option = {
            title: {text: '近7日订单成交额'},
            tooltip: {}, 
            xAxis: {name:'时间',data: lineDate},
            yAxis: {name:'销售额（￥）'},
            series: [
                {
                    data: reqData,
                    type: 'line',
                    lineStyle: {color: '#c69c6c',},
                    itemStyle :{color: '#c69c6c',}
                }
            ]
        }
        option && echartsChart.setOption(option);
    }
}
</script>

<style scoped>
    .echarts{
        width: 490px;
        height: 295px;
        border-radius: 8px;
        background: white;
        float: left;
        margin-right: 10px;
        margin-bottom: 10px;
        padding: 20px 10px;
    }
</style>